package com.ericxu.weixin.msg;

import org.dom4j.Document;

public class InvalidWeiXinMessage extends WeiXinMessage {
	private static final String FORMAT = "<xml>"
			+ "<ToUserName><![CDATA[%s]]></ToUserName>"
			+ "<FromUserName><![CDATA[%s]]></FromUserName>"
			+ "<CreateTime>%s</CreateTime>"
			+ "<MsgType><![CDATA[text]]></MsgType>"
			+ "<Content><![CDATA[%s]]></Content>"
			+ "<MsgId>%s</MsgId>"
			+ "</xml>";

	private String _content = "";
	
	public InvalidWeiXinMessage(Document doc) {
		super(null);
	}
	@Override
	public WeiXinMessage excute() {
		String frmUser = this.frmUserName;
		this.frmUserName = this.toUserName;
		this.toUserName = frmUser;
		this._content = "无法回答您的问题，很抱歉！";
		return this;
	}

	@Override
	public String toString() {
		return String.format(FORMAT, this.toUserName, this.frmUserName, this.createTime, 
				this._content, this.msgId);
	}
}
